﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using VisionCore;

namespace COER.PresenceData
{
    public partial class UC_ExcData : UserControl
    {
        public UC_ExcData()
        {
            InitializeComponent();
            GetControls(this.Controls);
        }

        private void GetControls(Control.ControlCollection ctrls)
        {
            foreach (Control item in ctrls)
            {
                if (item is Button && item.Tag?.ToString().Split('|')[0] == "btn")
                {
                    ((Button)item).Click += new EventHandler(this.btn_Switch_Click);
                }

                if (item is DLLPC.PCAP.PCButton && item.Tag?.ToString().Split('|')[0] == "btn")
                {
                    ((DLLPC.PCAP.PCButton)item).OP = Kernel.OP;
                }

                if (item.Controls != null)
                {
                    GetControls(item.Controls);
                }
            }
        }

        public void Load()
        {
            timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (this.Visible == false) return;

            
            if ( ProcedureHelper_Exc.ExcSTCodeScanEnable&& ProcedureHelper_EQ.AutoMode)
            {
                if (frmChipData_ExcST == null)
                {
                    frmChipData_ExcST = new FormChipData();
                }
                frmChipData_ExcST.ShowForm(1, ParameterHelper.ExcST);
            }
            else if(ProcedureHelper_Exc.ExcSTCodeScanEnable&& ParameterHelper.ExcST.Wafer_ID!="" && ParameterHelper.ExcST.Wafer_ID !=null && ProcedureHelper_EQ.AutoMode)
            {
                frmChipData_ExcST.Close();
            }         
          
                FreshStatus();            
        }
        FormChipData frmChipData_ExcST;
        FormChipData frmChipData_ExcTR;
        FormChipData frmChipData_SortST;
        FormChipData frmChipData_SortSTNG;

        FormDieData frmDieData_LDTR1;
        FormDieData frmDieData_LDTR2;
        FormDieData frmDieData_LaserST1;
        FormDieData frmDieData_LaserST2;
        FormDieData frmDieData_LaserST3;
        FormDieData frmDieData_LaserST4;
        FormDieData frmDieData_LaserST5;
        FormDieData frmDieData_LaserST6;
        FormDieData frmDieData_LaserST7;
        FormDieData frmDieData_LaserST8;
        FormDieData frmDieData_ULDTR1;
        FormDieData frmDieData_ULDTR2;

        
        FormNGTrayData frmTrayData_ULDSTNG;       

        private void btn_Switch_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            string[] info = btn.Tag.ToString().Split('|');

            switch (info[1])
            {
                #region 在席
                case "ExcST":
                    {
                        if (frmChipData_ExcST == null)
                        {
                            frmChipData_ExcST = new FormChipData();
                        }
                        frmChipData_ExcST.ShowForm(1, ParameterHelper.ExcST);
                    }
                    break;
                case "ExcTR":
                    {
                        if (frmChipData_ExcTR == null)
                        {
                            frmChipData_ExcTR = new FormChipData();
                        }
                        frmChipData_ExcTR.ShowForm(5, ParameterHelper.ExcTR);
                    }
                    break;
                case "SortST":
                    {
                        if (frmChipData_SortST == null)
                        {
                            frmChipData_SortST = new FormChipData();
                        }
                        frmChipData_SortST.ShowForm(6, ParameterHelper.SortST);
                    }
                    break;
                case "SortSTNG":
                    {
                        if (frmChipData_SortSTNG == null)
                        {
                            frmChipData_SortSTNG = new FormChipData();
                        }
                        frmChipData_SortSTNG.ShowForm(7, ParameterHelper.SortSTNG);
                    }
                    break;
                case "LDTR1":
                    {

                        if (ProcedureHelper_Exc.LDTR_R_ULD)
                        {
                            if (frmDieData_LDTR2 == null)
                            {
                                frmDieData_LDTR2 = new FormDieData();
                            }
                            frmDieData_LDTR2.ShowForm(2, ParameterHelper.LDTR2);
                        }
                        else
                        {
                            if (frmDieData_LDTR1 == null)
                            {
                                frmDieData_LDTR1 = new FormDieData();
                            }
                            frmDieData_LDTR1.ShowForm(1, ParameterHelper.LDTR1);
                        }

                    }
                    break;
                case "LDTR2":
                    {
                        if (ProcedureHelper_Exc.LDTR_R_ULD)
                        {
                            if (frmDieData_LDTR1 == null)
                            {
                                frmDieData_LDTR1 = new FormDieData();
                            }
                            frmDieData_LDTR1.ShowForm(1, ParameterHelper.LDTR1);
                        }
                        else
                        {
                            if (frmDieData_LDTR2 == null)
                            {
                                frmDieData_LDTR2 = new FormDieData();
                            }
                            frmDieData_LDTR2.ShowForm(2, ParameterHelper.LDTR2);
                        }
                    }
                    break;
                case "LaserST1":
                    {
                            if (ProcedureHelper_Exc.LaserST_R_LD2)
                            {
                                if (frmDieData_LaserST2 == null)
                                {
                                    frmDieData_LaserST2 = new FormDieData();
                                }
                                frmDieData_LaserST2.ShowForm(4, ParameterHelper.LaserST2);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD3)
                            {
                                if (frmDieData_LaserST3 == null)
                                {
                                    frmDieData_LaserST3 = new FormDieData();
                                }
                                frmDieData_LaserST3.ShowForm(5, ParameterHelper.LaserST3);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD4)
                            {
                                if (frmDieData_LaserST4 == null)
                                {
                                    frmDieData_LaserST4 = new FormDieData();
                                }
                                frmDieData_LaserST4.ShowForm(6, ParameterHelper.LaserST4);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD5)
                            {
                                if (frmDieData_LaserST5 == null)
                                {
                                    frmDieData_LaserST5 = new FormDieData();
                                }   
                                frmDieData_LaserST5.ShowForm(7, ParameterHelper.LaserST5);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD6)
                            {
                                if (frmDieData_LaserST6 == null)
                                {
                                    frmDieData_LaserST6 = new FormDieData();
                                }   
                                frmDieData_LaserST6.ShowForm(8, ParameterHelper.LaserST6);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD7)
                            {
                                if (frmDieData_LaserST7 == null)
                                {
                                    frmDieData_LaserST7 = new FormDieData();
                                }   
                                frmDieData_LaserST7.ShowForm(9, ParameterHelper.LaserST7);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD8)
                            {
                                if (frmDieData_LaserST8 == null)
                                {
                                    frmDieData_LaserST8 = new FormDieData();
                                }   
                                frmDieData_LaserST8.ShowForm(10, ParameterHelper.LaserST8);
                            }
                            else
                            {
                                if (frmDieData_LaserST1 == null)
                                {
                                    frmDieData_LaserST1 = new FormDieData();
                                }
                                 frmDieData_LaserST1.ShowForm(3, ParameterHelper.LaserST1);
                            }
                    }
                    break;
                case "LaserST2":
                    {
                            if (ProcedureHelper_Exc.LaserST_R_LD8)
                            {
                                if (frmDieData_LaserST1 == null)
                                {
                                    frmDieData_LaserST1 = new FormDieData();
                                }
                                frmDieData_LaserST1.ShowForm(3, ParameterHelper.LaserST1);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD2)
                            {
                                if (frmDieData_LaserST3 == null)
                                {
                                    frmDieData_LaserST3 = new FormDieData();
                                }
                                frmDieData_LaserST3.ShowForm(5, ParameterHelper.LaserST3);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD3)
                            {
                                if (frmDieData_LaserST4 == null)
                                {
                                    frmDieData_LaserST4 = new FormDieData();
                                }
                                frmDieData_LaserST4.ShowForm(6, ParameterHelper.LaserST4);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD4)
                            {
                                if (frmDieData_LaserST5 == null)
                                {
                                    frmDieData_LaserST5 = new FormDieData();
                                }
                                frmDieData_LaserST5.ShowForm(7, ParameterHelper.LaserST5);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD5)
                            {
                                if (frmDieData_LaserST6 == null)
                                {
                                    frmDieData_LaserST6 = new FormDieData();
                                }
                                frmDieData_LaserST6.ShowForm(8, ParameterHelper.LaserST6);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD6)
                            {
                                if (frmDieData_LaserST7 == null)
                                {
                                    frmDieData_LaserST7 = new FormDieData();
                                }
                                frmDieData_LaserST7.ShowForm(9, ParameterHelper.LaserST7);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD7)
                            {
                                if (frmDieData_LaserST8 == null)
                                {
                                    frmDieData_LaserST8 = new FormDieData();
                                }
                                frmDieData_LaserST8.ShowForm(10, ParameterHelper.LaserST8);
                            }
                           else
                           {
                                if (frmDieData_LaserST2 == null)
                                {
                                   frmDieData_LaserST2 = new FormDieData();
                                }
                                   frmDieData_LaserST2.ShowForm(4, ParameterHelper.LaserST2);
                           }
                    }
                    break;
                case "LaserST3":
                    {
                            if (ProcedureHelper_Exc.LaserST_R_LD7)
                            {
                                if (frmDieData_LaserST1 == null)
                                {
                                    frmDieData_LaserST1 = new FormDieData();
                                }
                                frmDieData_LaserST1.ShowForm(3, ParameterHelper.LaserST1);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD8)
                            {
                                if (frmDieData_LaserST2 == null)
                                {
                                    frmDieData_LaserST2 = new FormDieData();
                                }
                                frmDieData_LaserST2.ShowForm(4, ParameterHelper.LaserST2);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD2)
                            {
                                if (frmDieData_LaserST4 == null)
                                {
                                    frmDieData_LaserST4 = new FormDieData();
                                }
                                frmDieData_LaserST4.ShowForm(6, ParameterHelper.LaserST4);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD3)
                            {
                                if (frmDieData_LaserST5 == null)
                                {
                                    frmDieData_LaserST5 = new FormDieData();
                                }
                                frmDieData_LaserST5.ShowForm(7, ParameterHelper.LaserST5);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD4)
                            {
                                if (frmDieData_LaserST6 == null)
                                {
                                    frmDieData_LaserST6 = new FormDieData();
                                }
                                frmDieData_LaserST6.ShowForm(8, ParameterHelper.LaserST6);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD5)
                            {
                                if (frmDieData_LaserST7 == null)
                                {
                                    frmDieData_LaserST7 = new FormDieData();
                                }
                                frmDieData_LaserST7.ShowForm(9, ParameterHelper.LaserST7);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD6)
                            {
                                if (frmDieData_LaserST8 == null)
                                {
                                    frmDieData_LaserST8 = new FormDieData();
                                }
                                frmDieData_LaserST8.ShowForm(10, ParameterHelper.LaserST8);
                            }
                            else
                            {
                                if (frmDieData_LaserST3 == null)
                                {
                                    frmDieData_LaserST3 = new FormDieData();
                                }
                                frmDieData_LaserST3.ShowForm(5, ParameterHelper.LaserST3);
                            }
                     }
                    break;
                case "LaserST4":
                    {
                            if (ProcedureHelper_Exc.LaserST_R_LD6)
                            {
                                if (frmDieData_LaserST1 == null)
                                {
                                    frmDieData_LaserST1 = new FormDieData();
                                }
                                frmDieData_LaserST1.ShowForm(3, ParameterHelper.LaserST1);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD7)
                            {
                                if (frmDieData_LaserST2 == null)
                                {
                                    frmDieData_LaserST2 = new FormDieData();
                                }
                                frmDieData_LaserST2.ShowForm(4, ParameterHelper.LaserST2);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD8)
                            {
                                if (frmDieData_LaserST3 == null)
                                {
                                    frmDieData_LaserST3 = new FormDieData();
                                }
                                frmDieData_LaserST3.ShowForm(5, ParameterHelper.LaserST3);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD2)
                            {
                                if (frmDieData_LaserST5 == null)
                                {
                                    frmDieData_LaserST5 = new FormDieData();
                                }
                                frmDieData_LaserST5.ShowForm(7, ParameterHelper.LaserST5);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD3)
                            {
                                if (frmDieData_LaserST6 == null)
                                {
                                    frmDieData_LaserST6 = new FormDieData();
                                }
                                frmDieData_LaserST6.ShowForm(8, ParameterHelper.LaserST6);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD4)
                            {
                                if (frmDieData_LaserST7 == null)
                                {
                                    frmDieData_LaserST7 = new FormDieData();
                                }
                                frmDieData_LaserST7.ShowForm(9, ParameterHelper.LaserST7);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD5)
                            {
                                if (frmDieData_LaserST8 == null)
                                {
                                    frmDieData_LaserST8 = new FormDieData();
                                }
                                frmDieData_LaserST8.ShowForm(10, ParameterHelper.LaserST8);
                            }
                            else
                            {
                                if (frmDieData_LaserST4 == null)
                                {
                                    frmDieData_LaserST4 = new FormDieData();
                                }
                                frmDieData_LaserST4.ShowForm(6, ParameterHelper.LaserST4);
                            }
                    }
                    break;
                case "LaserST5":
                    {
                            if (ProcedureHelper_Exc.LaserST_R_LD5)
                            {
                                if (frmDieData_LaserST1 == null)
                                {
                                    frmDieData_LaserST1 = new FormDieData();
                                }
                                frmDieData_LaserST1.ShowForm(3, ParameterHelper.LaserST1);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD6)
                            {
                                if (frmDieData_LaserST2 == null)
                                {
                                    frmDieData_LaserST2 = new FormDieData();
                                }
                                frmDieData_LaserST2.ShowForm(4, ParameterHelper.LaserST2);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD7)
                            {
                                if (frmDieData_LaserST3 == null)
                                {
                                    frmDieData_LaserST3 = new FormDieData();
                                }
                                frmDieData_LaserST3.ShowForm(5, ParameterHelper.LaserST3);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD8)
                            {
                                if (frmDieData_LaserST4 == null)
                                {
                                    frmDieData_LaserST4 = new FormDieData();
                                }
                                frmDieData_LaserST4.ShowForm(6, ParameterHelper.LaserST4);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD2)
                            {
                                if (frmDieData_LaserST6 == null)
                                {
                                    frmDieData_LaserST6 = new FormDieData();
                                }
                                frmDieData_LaserST6.ShowForm(8, ParameterHelper.LaserST6);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD3)
                            {
                                if (frmDieData_LaserST7 == null)
                                {
                                    frmDieData_LaserST7 = new FormDieData();
                                }
                                frmDieData_LaserST7.ShowForm(9, ParameterHelper.LaserST7);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD4)
                            {
                                if (frmDieData_LaserST8 == null)
                                {
                                    frmDieData_LaserST8 = new FormDieData();
                                }
                                frmDieData_LaserST8.ShowForm(10, ParameterHelper.LaserST8);
                            }
                            else
                            {
                                if (frmDieData_LaserST5 == null)
                                {
                                    frmDieData_LaserST5 = new FormDieData();
                                }
                                frmDieData_LaserST5.ShowForm(7, ParameterHelper.LaserST5);
                            }
                    }
                    break;
                case "LaserST6":
                    {
                            if (ProcedureHelper_Exc.LaserST_R_LD4)
                            {
                                if (frmDieData_LaserST1 == null)
                                {
                                    frmDieData_LaserST1 = new FormDieData();
                                }
                                frmDieData_LaserST1.ShowForm(3, ParameterHelper.LaserST1);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD5)
                            {
                                if (frmDieData_LaserST2 == null)
                                {
                                    frmDieData_LaserST2 = new FormDieData();
                                }
                                frmDieData_LaserST2.ShowForm(4, ParameterHelper.LaserST2);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD6)
                            {
                                if (frmDieData_LaserST3 == null)
                                {
                                    frmDieData_LaserST3 = new FormDieData();
                                }
                                frmDieData_LaserST3.ShowForm(5, ParameterHelper.LaserST3);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD7)
                            {
                                if (frmDieData_LaserST4 == null)
                                {
                                    frmDieData_LaserST4 = new FormDieData();
                                }
                                frmDieData_LaserST4.ShowForm(6, ParameterHelper.LaserST4);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD8)
                            {
                                if (frmDieData_LaserST5 == null)
                                {
                                    frmDieData_LaserST5 = new FormDieData();
                                }
                                frmDieData_LaserST5.ShowForm(7, ParameterHelper.LaserST5);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD2)
                            {
                                if (frmDieData_LaserST7 == null)
                                {
                                    frmDieData_LaserST7 = new FormDieData();
                                }
                                frmDieData_LaserST7.ShowForm(9, ParameterHelper.LaserST7);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD3)
                            {
                                if (frmDieData_LaserST8 == null)
                                {
                                    frmDieData_LaserST8 = new FormDieData();
                                }
                                frmDieData_LaserST8.ShowForm(10, ParameterHelper.LaserST8);
                            }
                            else
                            {
                                if (frmDieData_LaserST6 == null)
                                {
                                    frmDieData_LaserST6 = new FormDieData();
                                }
                                frmDieData_LaserST6.ShowForm(8, ParameterHelper.LaserST6);
                            }
                    }
                    break;
                case "LaserST7":
                    {
                            if (ProcedureHelper_Exc.LaserST_R_LD3)
                            {
                                if (frmDieData_LaserST1 == null)
                                {
                                    frmDieData_LaserST1 = new FormDieData();
                                }
                                frmDieData_LaserST1.ShowForm(3, ParameterHelper.LaserST1);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD4)
                            {
                                if (frmDieData_LaserST2 == null)
                                {
                                    frmDieData_LaserST2 = new FormDieData();
                                }
                                frmDieData_LaserST2.ShowForm(4, ParameterHelper.LaserST2);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD5)
                            {
                                if (frmDieData_LaserST3 == null)
                                {
                                    frmDieData_LaserST3 = new FormDieData();
                                }
                                frmDieData_LaserST3.ShowForm(5, ParameterHelper.LaserST3);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD6)
                            {
                                if (frmDieData_LaserST4 == null)
                                {
                                    frmDieData_LaserST4 = new FormDieData();
                                }
                                frmDieData_LaserST4.ShowForm(6, ParameterHelper.LaserST4);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD7)
                            {
                                if (frmDieData_LaserST5 == null)
                                {
                                    frmDieData_LaserST5 = new FormDieData();
                                }
                                frmDieData_LaserST5.ShowForm(7, ParameterHelper.LaserST5);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD8)
                            {
                                if (frmDieData_LaserST6 == null)
                                {
                                    frmDieData_LaserST6 = new FormDieData();
                                }
                                frmDieData_LaserST6.ShowForm(8, ParameterHelper.LaserST6);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD2)
                            {
                                if (frmDieData_LaserST8 == null)
                                {
                                    frmDieData_LaserST8 = new FormDieData();
                                }
                                frmDieData_LaserST8.ShowForm(10, ParameterHelper.LaserST8);
                            }
                            else
                            {
                                if (frmDieData_LaserST7 == null)
                                {
                                    frmDieData_LaserST7 = new FormDieData();
                                }
                                frmDieData_LaserST7.ShowForm(9, ParameterHelper.LaserST7);
                            }
                    }
                    break;
                case "LaserST8":
                    {
                            if (ProcedureHelper_Exc.LaserST_R_LD2)
                            {
                                if (frmDieData_LaserST1 == null)
                                {
                                    frmDieData_LaserST1 = new FormDieData();
                                }
                                frmDieData_LaserST1.ShowForm(3, ParameterHelper.LaserST1);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD3)
                            {
                                if (frmDieData_LaserST2 == null)
                                {
                                    frmDieData_LaserST2 = new FormDieData();
                                }
                                frmDieData_LaserST2.ShowForm(4, ParameterHelper.LaserST2);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD4)
                            {
                                if (frmDieData_LaserST3 == null)
                                {
                                    frmDieData_LaserST3 = new FormDieData();
                                }
                                frmDieData_LaserST3.ShowForm(5, ParameterHelper.LaserST3);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD5)
                            {
                                if (frmDieData_LaserST4 == null)
                                {
                                    frmDieData_LaserST4 = new FormDieData();
                                }
                                frmDieData_LaserST4.ShowForm(6, ParameterHelper.LaserST4);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD6)
                            {
                                if (frmDieData_LaserST5 == null)
                                {
                                    frmDieData_LaserST5 = new FormDieData();
                                }
                                frmDieData_LaserST5.ShowForm(7, ParameterHelper.LaserST5);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD7)
                            {
                                if (frmDieData_LaserST6 == null)
                                {
                                    frmDieData_LaserST6 = new FormDieData();
                                }
                                frmDieData_LaserST6.ShowForm(8, ParameterHelper.LaserST6);
                            }
                            else if (ProcedureHelper_Exc.LaserST_R_LD8)
                            {
                                if (frmDieData_LaserST7 == null)
                                {
                                    frmDieData_LaserST7 = new FormDieData();
                                }
                                frmDieData_LaserST7.ShowForm(9, ParameterHelper.LaserST7);
                            }
                            else
                            {
                                if (frmDieData_LaserST8 == null)
                                {
                                    frmDieData_LaserST8 = new FormDieData();
                                }
                                frmDieData_LaserST8.ShowForm(10, ParameterHelper.LaserST8);
                            }
                    }                  
                    break;
                case "ULDTR1":
                    {                                              
                        if (ProcedureHelper_Exc.ULDTR_R_ULD)
                        {
                            if (frmDieData_ULDTR2 == null)
                            {
                                frmDieData_ULDTR2 = new FormDieData();
                            }
                            frmDieData_ULDTR2.ShowForm(12, ParameterHelper.ULDTR2);
                        }
                        else
                        {
                            if (frmDieData_ULDTR1 == null)
                            {
                                frmDieData_ULDTR1 = new FormDieData();
                            }
                            frmDieData_ULDTR1.ShowForm(11, ParameterHelper.ULDTR1);
                        }
                    }
                    break;
                case "ULDTR2":
                    {
                        if (ProcedureHelper_Exc.ULDTR_R_ULD)
                        {
                            if (frmDieData_ULDTR1 == null)
                            {
                                frmDieData_ULDTR1 = new FormDieData();
                            }
                            frmDieData_ULDTR1.ShowForm(11, ParameterHelper.ULDTR1);
                        }
                        else
                        {
                            if (frmDieData_ULDTR2 == null)
                            {
                                frmDieData_ULDTR2 = new FormDieData();
                            }
                            frmDieData_ULDTR2.ShowForm(12, ParameterHelper.ULDTR2);
                        }
                    }
                    break;
               
                    #endregion
            }
        }

        private void FreshStatus()
        {
          
            if (Kernel.motion.ULDTR_R.AxisMotionStatus.Stop == 1)
            {
                if (ProcedureHelper_Exc.ULDTR_R_ULD)
                {
                    //lblULDTR1.Text = "2";
                    //lblULDTR2.Text = "1";
                    //btnULDTR1.Text = ParameterHelper.ULDTR2.Laser_ID;
                    //btnULDTR2.Text = ParameterHelper.ULDTR1.Laser_ID;
                    //btnULDTR1.BackColor = WorkDataStatus(ParameterHelper.ULDTR2.Enable, (ProcedureHelper_Exc.ULDTR_2_Clamp_Close && Kernel.motion.ULDTR_2_Clamp.AxisMotionI.INP == 1) || ProcedureHelper_EQ.DryRunMode);
                    //btnULDTR2.BackColor = WorkDataStatus(ParameterHelper.ULDTR1.Enable, (ProcedureHelper_Exc.ULDTR_1_Clamp_Close && Kernel.motion.ULDTR_1_Clamp.AxisMotionI.INP == 1) || ProcedureHelper_EQ.DryRunMode);
                }
                else
                {
                    //lblULDTR1.Text = "1";
                    //lblULDTR2.Text = "2";
                    //btnULDTR1.Text = ParameterHelper.ULDTR1.Laser_ID;
                    //btnULDTR2.Text = ParameterHelper.ULDTR2.Laser_ID;
                    //btnULDTR1.BackColor = WorkDataStatus(ParameterHelper.ULDTR1.Enable, (ProcedureHelper_Exc.ULDTR_1_Clamp_Close && Kernel.motion.ULDTR_1_Clamp.AxisMotionI.INP == 1) || ProcedureHelper_EQ.DryRunMode);
                    //btnULDTR2.BackColor = WorkDataStatus(ParameterHelper.ULDTR2.Enable, (ProcedureHelper_Exc.ULDTR_2_Clamp_Close && Kernel.motion.ULDTR_2_Clamp.AxisMotionI.INP == 1) || ProcedureHelper_EQ.DryRunMode);
                }
            }
            if (Kernel.motion.LaserST_R.AxisMotionStatus.Stop == 1)
            {
                if (ProcedureHelper_Exc.LaserST_R_LD2)
                {
                    //btnLaserST1.BackColor = WorkDataStatus(ParameterHelper.LaserST2.Enable, ProcedureHelper_Exc.LaserST2_Vac || ProcedureHelper_EQ.DryRunMode);
                    //btnLaserST2.BackColor = WorkDataStatus(ParameterHelper.LaserST3.Enable, ProcedureHelper_Exc.LaserST3_Vac || ProcedureHelper_EQ.DryRunMode);
                    //btnLaserST3.BackColor = WorkDataStatus(ParameterHelper.LaserST4.Enable, ProcedureHelper_Exc.LaserST4_Vac || ProcedureHelper_EQ.DryRunMode);
                    //btnLaserST4.BackColor = WorkDataStatus(ParameterHelper.LaserST5.Enable, ProcedureHelper_Exc.LaserST5_Vac || ProcedureHelper_EQ.DryRunMode);
                    //btnLaserST5.BackColor = WorkDataStatus(ParameterHelper.LaserST6.Enable, ProcedureHelper_Exc.LaserST6_Vac || ProcedureHelper_EQ.DryRunMode);
                    //btnLaserST6.BackColor = WorkDataStatus(ParameterHelper.LaserST7.Enable, ProcedureHelper_Exc.LaserST7_Vac || ProcedureHelper_EQ.DryRunMode);
                    //btnLaserST7.BackColor = WorkDataStatus(ParameterHelper.LaserST8.Enable, ProcedureHelper_Exc.LaserST8_Vac || ProcedureHelper_EQ.DryRunMode);
                    //btnLaserST8.BackColor = WorkDataStatus(ParameterHelper.LaserST1.Enable, ProcedureHelper_Exc.LaserST1_Vac || ProcedureHelper_EQ.DryRunMode);
                }
                else if (ProcedureHelper_Exc.LaserST_R_LD3)
                {
                    

                    //btnLaserST1.BackColor = WorkDataStatus(ParameterHelper.LaserST3.Enable, ProcedureHelper_Exc.LaserST3_Vac || ProcedureHelper_EQ.DryRunMode);
                    //btnLaserST2.BackColor = WorkDataStatus(ParameterHelper.LaserST4.Enable, ProcedureHelper_Exc.LaserST4_Vac || ProcedureHelper_EQ.DryRunMode);
                    //btnLaserST3.BackColor = WorkDataStatus(ParameterHelper.LaserST5.Enable, ProcedureHelper_Exc.LaserST5_Vac || ProcedureHelper_EQ.DryRunMode);
                    //btnLaserST4.BackColor = WorkDataStatus(ParameterHelper.LaserST6.Enable, ProcedureHelper_Exc.LaserST6_Vac || ProcedureHelper_EQ.DryRunMode);
                    //btnLaserST5.BackColor = WorkDataStatus(ParameterHelper.LaserST7.Enable, ProcedureHelper_Exc.LaserST7_Vac || ProcedureHelper_EQ.DryRunMode);
                    //btnLaserST6.BackColor = WorkDataStatus(ParameterHelper.LaserST8.Enable, ProcedureHelper_Exc.LaserST8_Vac || ProcedureHelper_EQ.DryRunMode);
                    //btnLaserST7.BackColor = WorkDataStatus(ParameterHelper.LaserST1.Enable, ProcedureHelper_Exc.LaserST1_Vac || ProcedureHelper_EQ.DryRunMode);
                    //btnLaserST8.BackColor = WorkDataStatus(ParameterHelper.LaserST2.Enable, ProcedureHelper_Exc.LaserST2_Vac || ProcedureHelper_EQ.DryRunMode);
                }
                
            }



            //btnLDTray1.BackColor = WorkDataStatus(Kernel.Efem.DI.X097_Tray_LD_Prensence1 == 0, Kernel.Efem.DI.X097_Tray_LD_Prensence1 == 0);
            //btnLDTray2.BackColor = WorkDataStatus(Kernel.Efem.DI.X098_Tray_LD_Prensence2 == 0, Kernel.Efem.DI.X098_Tray_LD_Prensence2 == 0);
            //btnLDTray3.BackColor = WorkDataStatus(Kernel.Efem.DI.X099_Tray_LD_Prensence3 == 0, Kernel.Efem.DI.X099_Tray_LD_Prensence3 == 0);
            //btnLDTray4.BackColor = WorkDataStatus(Kernel.Efem.DI.X09A_Tray_LD_Prensence4 == 0, Kernel.Efem.DI.X09A_Tray_LD_Prensence4 == 0);
            //btnLDTray5.BackColor = WorkDataStatus(Kernel.Efem.DI.X09B_Tray_LD_Prensence5 == 0, Kernel.Efem.DI.X09B_Tray_LD_Prensence5 == 0);

            btnULDTray1.Text = ParameterHelper.ULDTray1.Wafer_ID;
            btnULDTray2.Text = ParameterHelper.ULDTray2.Wafer_ID;
            btnULDTray3.Text = ParameterHelper.ULDTray3.Wafer_ID;
            btnULDTray4.Text = ParameterHelper.ULDTray4.Wafer_ID;
            btnULDTray5.Text = ParameterHelper.ULDTray5.Wafer_ID;
            //btnULDTray1.BackColor = WorkDataStatus(ParameterHelper.ULDTray1.Enable, Kernel.Efem.DI.X0A0_Tray_ULD_Prensence1 == 0 );
            //btnULDTray2.BackColor = WorkDataStatus(ParameterHelper.ULDTray2.Enable, Kernel.Efem.DI.X0A1_Tray_ULD_Prensence2 == 0 );
            //btnULDTray3.BackColor = WorkDataStatus(ParameterHelper.ULDTray3.Enable, Kernel.Efem.DI.X0A2_Tray_ULD_Prensence3 == 0 );
            //btnULDTray4.BackColor = WorkDataStatus(ParameterHelper.ULDTray4.Enable, Kernel.Efem.DI.X0A3_Tray_ULD_Prensence4 == 0 );
            //btnULDTray5.BackColor = WorkDataStatus(ParameterHelper.ULDTray5.Enable, Kernel.Efem.DI.X0A4_Tray_ULD_Prensence5 == 0 );

        }
        private Color WorkDataStatus(bool DataEnable, bool Exist)
        {
            Color myColor;
            if (DataEnable && Exist)
            {
                myColor = Color.Green;
            }
            else
            {
                if (!DataEnable && !Exist)
                {
                    myColor = Color.White;
                }
                else
                {
                    myColor = (DataEnable) ? Color.Red : Color.Yellow;
                }
            }
            return myColor;
        }

        private void label10_Click(object sender, EventArgs e)
        {

        }
    }
}
